<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Flow: flow::error Namespace Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Flow<span id="projectnumber">&#160;2.0.0</span>
   </div>
   <div id="projectbrief">Flow project: Public API.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceflow.html">flow</a></li><li class="navelem"><a class="el" href="namespaceflow_1_1error.html">error</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">flow::error Namespace Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Flow module that facilitates working with error codes and exceptions; essentially comprised of niceties on top <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a>'s error facility.  
<a href="namespaceflow_1_1error.html#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classflow_1_1error_1_1Runtime__error.html">Runtime_error</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">An <code>std::runtime_error</code> (which is an <code>std::exception</code>) that stores an <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">Error_code</a>.  <a href="classflow_1_1error_1_1Runtime__error.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aa3708bdd4ceb1a6c801f3d4a1fc10f6d"><td class="memTemplParams" colspan="2">template&lt;typename Func , typename Ret &gt; </td></tr>
<tr class="memitem:aa3708bdd4ceb1a6c801f3d4a1fc10f6d"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespaceflow_1_1error.html#aa3708bdd4ceb1a6c801f3d4a1fc10f6d">exec_and_throw_on_error</a> (const Func &amp;func, Ret *ret, <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> *err_code, <a class="el" href="namespaceflow_1_1util.html#ae4dc52186797094b3040379ff19124c9">util::String_view</a> context)</td></tr>
<tr class="memdesc:aa3708bdd4ceb1a6c801f3d4a1fc10f6d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Helper for <a class="el" href="error_2error_8hpp.html#a636b2d30a8785df6e84646b568bce9b5" title="Narrow-use macro that implements the error code/exception semantics expected of most public-facing Fl...">FLOW_ERROR_EXEC_AND_THROW_ON_ERROR()</a> macro that does everything in the latter not needing a preprocessor.  <a href="namespaceflow_1_1error.html#aa3708bdd4ceb1a6c801f3d4a1fc10f6d">More...</a><br /></td></tr>
<tr class="separator:aa3708bdd4ceb1a6c801f3d4a1fc10f6d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a48afa7f8c2e100acd461365dfb00a114"><td class="memTemplParams" colspan="2">template&lt;typename Func &gt; </td></tr>
<tr class="memitem:a48afa7f8c2e100acd461365dfb00a114"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespaceflow_1_1error.html#a48afa7f8c2e100acd461365dfb00a114">exec_void_and_throw_on_error</a> (const Func &amp;func, <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> *err_code, <a class="el" href="namespaceflow_1_1util.html#ae4dc52186797094b3040379ff19124c9">util::String_view</a> context)</td></tr>
<tr class="memdesc:a48afa7f8c2e100acd461365dfb00a114"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent of <a class="el" href="namespaceflow_1_1error.html#aa3708bdd4ceb1a6c801f3d4a1fc10f6d" title="Helper for FLOW_ERROR_EXEC_AND_THROW_ON_ERROR() macro that does everything in the latter not needing ...">exec_and_throw_on_error()</a> for operations with <code>void</code> return type.  <a href="namespaceflow_1_1error.html#a48afa7f8c2e100acd461365dfb00a114">More...</a><br /></td></tr>
<tr class="separator:a48afa7f8c2e100acd461365dfb00a114"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Flow module that facilitates working with error codes and exceptions; essentially comprised of niceties on top <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a>'s error facility. </p>
<p >As of this writing, we feel the latter facility is fantastic and quite complete; so as of this writing <a class="el" href="namespaceflow_1_1error.html" title="Flow module that facilitates working with error codes and exceptions; essentially comprised of niceti...">flow::error</a> is intended to contain only minor syntactic-sugary items.</p>
<dl class="section note"><dt>Note</dt><dd>Flow uses the convention wherein error-related facilities of a particular Flow module X (in <code>namespace flow::X</code>) &ndash; especially in particular X's dedicated error code set, if any &ndash; are to reside in <code>namespace flow::X::error</code>, mirroring the naming of up-one-level-from-that <code><a class="el" href="namespaceflow_1_1error.html" title="Flow module that facilitates working with error codes and exceptions; essentially comprised of niceti...">flow::error</a></code>.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> whose doc header introduces the error-emission conventions used in all Flow modules. </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="aa3708bdd4ceb1a6c801f3d4a1fc10f6d" name="aa3708bdd4ceb1a6c801f3d4a1fc10f6d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa3708bdd4ceb1a6c801f3d4a1fc10f6d">&#9670;&nbsp;</a></span>exec_and_throw_on_error()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Func , typename Ret &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool flow::error::exec_and_throw_on_error </td>
          <td>(</td>
          <td class="paramtype">const Func &amp;&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Ret *&#160;</td>
          <td class="paramname"><em>ret</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> *&#160;</td>
          <td class="paramname"><em>err_code</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceflow_1_1util.html#ae4dc52186797094b3040379ff19124c9">util::String_view</a>&#160;</td>
          <td class="paramname"><em>context</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Helper for <a class="el" href="error_2error_8hpp.html#a636b2d30a8785df6e84646b568bce9b5" title="Narrow-use macro that implements the error code/exception semantics expected of most public-facing Fl...">FLOW_ERROR_EXEC_AND_THROW_ON_ERROR()</a> macro that does everything in the latter not needing a preprocessor. </p>
<p >Probably not to be called except by that macro.</p>
<p >This function is the meat of it. I omit details, since they are explained in <a class="el" href="error_2error_8hpp.html#a636b2d30a8785df6e84646b568bce9b5" title="Narrow-use macro that implements the error code/exception semantics expected of most public-facing Fl...">FLOW_ERROR_EXEC_AND_THROW_ON_ERROR()</a> doc header. The present function does what is described therein &ndash; except for preprocessor-requiring actions:</p>
<p >Preprocessor is needed to (1) supply halfway-decent "context" (file/line #/etc.) info to the exception object; and (2) to trigger the invoker of the macro (the actual user-facing API or very close to it) to return XYZ to <em>its</em> caller (user code or very close to it). So this function cannot do that, but instead it respectively (1) takes the context string as an argument; and (2) returns <code>true</code> if and only if the invoker of the macro should in fact immediately return the value <code>*ret</code>, where <code>ret</code> is an "out" argument to the present function.</p>
<dl class="section note"><dt>Note</dt><dd>ATTENTION! This is a (rare) case where documentation is more complicated than just looking at the implementation. This embarrassingly verbose doc header is sort of a pedantic formality in this particular (rare) case and is probably not worth reading for most people. </dd></dl>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">Func</td><td>Any type such that given an instance <code>Func f</code>, the expression <code>r = f(&amp;e_c)</code> is valid, assuming <code>e_c</code> is an <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">Error_code</a>, and <code>r</code> is a <code>Ret</code>. In practice, this is usually the insane type of whatever concoction lambda or <code>bind()</code> conjures out of a plain, hard-working method like Peer_socket::send() and a bunch of innocent, API user-originated arguments thereto. </td></tr>
    <tr><td class="paramname">Ret</td><td>The return type of the operation <code>func()</code>. Should equal <code>ARG_ret_type</code> of <a class="el" href="error_2error_8hpp.html#a636b2d30a8785df6e84646b568bce9b5" title="Narrow-use macro that implements the error code/exception semantics expected of most public-facing Fl...">FLOW_ERROR_EXEC_AND_THROW_ON_ERROR()</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">func</td><td>The operation, with the return type and argument as described above in <code>Func</code> template argument doc, that performs whatever possibly error-generating actions are being wrapped by all this; and returns whatever value is intended for the ultimate API caller. The <code>Error_code*</code> passed into <code>func()</code> will NOT be null; thus <code>func()</code> must NOT throw <a class="el" href="classflow_1_1error_1_1Runtime__error.html" title="An std::runtime_error (which is an std::exception) that stores an Error_code.">Runtime_error</a> on error. </td></tr>
    <tr><td class="paramname">ret</td><td>Non-null pointer to a value into which the present function will place the return value of <code>func()</code>, if indeed it executes the latter (and thus <code>true</code> is returned). </td></tr>
    <tr><td class="paramname">err_code</td><td>Null; or non-null pointer to an error code in memory; probably originating from the API caller. <code>*err_code</code> is set if and only if <code>err_code</code> was non-null; and <code>func()</code> was executed (thus <code>true</code> returned); and <code>func()</code> encountered an error. </td></tr>
    <tr><td class="paramname">context</td><td>Value suitable for the <code>context</code> argument of <a class="el" href="classflow_1_1error_1_1Runtime__error.html" title="An std::runtime_error (which is an std::exception) that stores an Error_code.">Runtime_error</a> constructor. Most likely this should be something it takes little to no runtime computation to obtain; so either your own string literal; or FLOW_UTIL_WHERE_AM_I_LITERAL(). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if and only if <code>err_code</code> is null; and therefore <code>func()</code> was called. <code>false</code> otherwise (i.e., <code>err_code</code> is not null; nothing was done; and the caller should perform the equivalent of <code>func()</code> while safely assuming <code>*err_code</code> may be assigned to upon error). </dd></dl>

</div>
</div>
<a id="a48afa7f8c2e100acd461365dfb00a114" name="a48afa7f8c2e100acd461365dfb00a114"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a48afa7f8c2e100acd461365dfb00a114">&#9670;&nbsp;</a></span>exec_void_and_throw_on_error()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Func &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool flow::error::exec_void_and_throw_on_error </td>
          <td>(</td>
          <td class="paramtype">const Func &amp;&#160;</td>
          <td class="paramname"><em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> *&#160;</td>
          <td class="paramname"><em>err_code</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceflow_1_1util.html#ae4dc52186797094b3040379ff19124c9">util::String_view</a>&#160;</td>
          <td class="paramname"><em>context</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Equivalent of <a class="el" href="namespaceflow_1_1error.html#aa3708bdd4ceb1a6c801f3d4a1fc10f6d" title="Helper for FLOW_ERROR_EXEC_AND_THROW_ON_ERROR() macro that does everything in the latter not needing ...">exec_and_throw_on_error()</a> for operations with <code>void</code> return type. </p>
<p >Unlike the latter function, however, the present function is to be used directly as opposed to via macro.</p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">Func</td><td>Any type such that given an instance <code>Func f</code>, the expression <code>f(&amp;e_c)</code> is valid, assuming <code>e_c</code> is an <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">Error_code</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">func</td><td>The operation, with the return type <code>void</code> and argument as described above in <code>Func</code> template argument doc, that performs whatever possibly error-generating actions are being wrapped by all this. The <code>Error_code*</code> passed into <code>func()</code> will NOT be null; thus <code>func()</code> must NOT throw <a class="el" href="classflow_1_1error_1_1Runtime__error.html" title="An std::runtime_error (which is an std::exception) that stores an Error_code.">Runtime_error</a> on error. </td></tr>
    <tr><td class="paramname">err_code</td><td>See <a class="el" href="namespaceflow_1_1error.html#aa3708bdd4ceb1a6c801f3d4a1fc10f6d" title="Helper for FLOW_ERROR_EXEC_AND_THROW_ON_ERROR() macro that does everything in the latter not needing ...">exec_and_throw_on_error()</a>. </td></tr>
    <tr><td class="paramname">context</td><td>See <a class="el" href="namespaceflow_1_1error.html#aa3708bdd4ceb1a6c801f3d4a1fc10f6d" title="Helper for FLOW_ERROR_EXEC_AND_THROW_ON_ERROR() macro that does everything in the latter not needing ...">exec_and_throw_on_error()</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>See <a class="el" href="namespaceflow_1_1error.html#aa3708bdd4ceb1a6c801f3d4a1fc10f6d" title="Helper for FLOW_ERROR_EXEC_AND_THROW_ON_ERROR() macro that does everything in the latter not needing ...">exec_and_throw_on_error()</a>. </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 28 2025 22:55:32 for Flow by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
